package com.example.redisdemo.controller;

import com.example.redisdemo.model.RedisInfo;
import com.example.redisdemo.model.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import redis.clients.jedis.Jedis;

import java.util.ArrayList;
import java.util.List;

@Controller
public class StudentController {
    RedisInfo  ri = new RedisInfo();
    @RequestMapping(value = "student")
    public ModelAndView queryStudentBySno(String sno) {
        Jedis jedis = new Jedis(ri.getRIp(),ri.getRPort());
        jedis.set("name","modige");

        ModelAndView mvc = new ModelAndView("student");
        List<Student> studentList = new ArrayList<>();
        Student s = new Student();

        s.setSname(jedis.get("name"));

        mvc.addObject(s);
        return mvc;
    }
}
